<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        var status = '<?php echo $_GET['status'];?>';
        if(status == '-1'){
            alert('fail:<?php echo $_GET['msg'];?>');
        }

        function setDel(uid){
            if(confirm("确定删除该用户吗？")){
                var url = 'index.php?c=user&m=admin_del&uid='+uid;
                var param = {};
                common_ajax(url, param, function (data){
                    if(data.errorCode == 0) {
                        //表单提交
                        window.location.href=  window.location.href;
                        return true;
                    }else{
                        alert(data.errorMsg);
                    }
                });
            }
        }

        function is_persp(uid, is_persp){
            var url = 'index.php?c=user&m=set_persp';
            var param = {"uid":uid, "is_persp":is_persp};
            common_ajax(url, param, function (data){
                if(data.errorCode == 0) {
                    //表单提交
                    window.location.href=  window.location.href;
                    return true;
                }else{
                    alert(data.errorMsg);
                }
            });
        }
        function is_audit(uid, is_audit){
            var url = 'index.php?c=user&m=set_audit';
            var param = {"uid":uid, "is_audit":is_audit};
            common_ajax(url, param, function (data){
                if(data.errorCode == 0) {
                    //表单提交
                    window.location.href=  window.location.href;
                    return true;
                }else{
                    alert(data.errorMsg);
                }
            });
        }
        /**
         * 批量删除
         */
        function setDelList(){
            var ids = document.getElementsByName('uid[]');
            var sel_ids = '';
            for (var i = 0; i < ids.length; i++){
                if (ids[i].checked) {
                    sel_ids += ids[i].value + ',';
                }
            }
            if(sel_ids == ''){
                alert('请选择要删除的用户');
                return;
            }
            sel_ids = sel_ids.substr(0,sel_ids.length - 1);
            if(sel_ids == ''){
                alert('请选择要删除的项');
                return ;
            }
            setDel(sel_ids);
        }
    </script>

    <body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="add-btn" style="float:right;margin-bottom:5px;">
            <div class="modal fade" id="admin_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
                <div class="modal-dialog" style="width: 60%;"><div class="modal-content"></div></div>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <a href="index.php?c=user&m=admin_edit" class="btn btn-danger" data-toggle="modal" data-target="#admin_edit">添加</a>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal" id="f_form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                            <table class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
                                    <th>ID</th>
                                    <th>昵称</th>
                                    <th>手机号</th>
                                    <th>密码</th>
                                    <th>注册日期</th>
                                    <th>火眼金星</th>
                                    <th>前端审核</th>
                                    <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach($adminList as $user) { ?>
                                    <tr>
                                        <th scope="row">
                                            <input type="checkbox" name="uid[]" value="<?php echo $user['uid']; ?>" class="checkbox ck" />
                                        </th>
                                        <td><?php echo $user['uid']; ?></td>
                                        <td><?php echo $user['nickname']; ?></td>
                                        <td><?php echo $user['mobile']; ?></td>
                                        <td><?php echo $user['password']; ?></td>
                                        <td><?php echo date("Y-m-d H:i", $user['regdate']); ?></td>
                                        <td>
                                            <?php if($user["is_persp"] == 1){ ?>
                                                <a href="javascript:void(0)" onclick="is_persp(<?php echo $user['uid']; ?>, 0)" class="btn btn-white">关闭</a>
                                            <?php }else { ?>
                                                <a href="javascript:void(0)" onclick="is_persp(<?php echo $user['uid']; ?>, 1)" class="btn btn-white">开启</a>
                                            <?php } ?>
                                            <?php echo $user["is_persp"] == 1 ? "（已开启）" : "（否）";?>
                                        </td>
                                        <td>
                                            <?php if($user["is_audit"] == 1){ ?>
                                                <a href="javascript:void(0)" onclick="is_audit(<?php echo $user['uid']; ?>, 0)" class="btn btn-white">关闭</a>
                                            <?php }else { ?>
                                                <a href="javascript:void(0)" onclick="is_audit(<?php echo $user['uid']; ?>, 1)" class="btn btn-white">开启</a>
                                            <?php } ?>
                                            <?php echo $user["is_audit"] == 1 ? "（已开启）" : "（否）";?>
                                        </td>
                                        <td nowrap="nowrap">
                                            <a href="javascript:void(0)" onclick="setDel(<?php echo $user['uid']; ?>)" class="btn btn-white">删除</a>
                                        </td>
                                    </tr>
                                <?php }?>
                                </tbody>
                            </table>
                            <div class="set_page">
                                <div class="set_del">
                                    <label class="l_c_sel">
                                        <input type="checkbox" name="chkall" onclick="checkAll('prefix', this.form, 'uid')" class="checkbox c_sel" style="margin: 0px;display: inline;"/>全选
                                    </label>
                                    <a href="javascript:void(0)" onclick="setDelList()">删除</a>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>


<?php  include VIEWPATH.'common/footer.php';  ?>